#ifndef _ENCODER_H
#define _ENCODER_H

#include "motor.h"

typedef struct
{
	int16_t MecAngleOffset;
	
	int16_t AccumTheta;

	int16_t ElethetaLast;  //electric angle
	
	uint8_t OffsetFlag;
	uint8_t Direction;
	
	uint16_t Cz;
	uint16_t Ce;
	
	int16_t ElecAngle;	
	uint8_t AccumThetaCnt;
	
	int16_t vel_cl;
	int16_t m_vel; 
	
	int16_t EncoderSpeed;
	int16_t Preset_cnt;
		
}
Encoder_t;

void Encoder_Control_Init(void);

void Encoder_Angle_Read(void);

void Encoder_Offset_Calc(void);

void Encoder_Speed_Calc(void);
void Encoder_Cnt_Clear(void);
void ENC_Vel(void) ;
void ENC_Curr(void);
extern Encoder_t Encoder;
#endif

